#define _CRT_SECURE_NO_WARNINGS
#include"Heap.h"
int test()
{
	Heap  heap;
	HeapInit(&heap);
	int arr[] = {5,5,4,4,2,2};
	int size = sizeof(arr) / sizeof(int);
	for (int i = 0; i < size; i++) {
		HeapPush(&heap, arr[i]);
	}
	while (HeapEmpty(&heap))
	{
		if (heap.size == 1) {
			return HeapTop(&heap);
		}
		int y = HeapTop(&heap);
		HeapPop(&heap);
		int x = HeapTop(&heap);
		if (y == x) {
			HeapPop(&heap);
		}
		else {
			HeapPop(&heap);
			HeapPush(&heap, y - x);
		}
	}
	return 0;
}
int main()
{
	int ret=test();
	printf("%d ", ret);
	return 0;
}